-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[spe_sms_datato44_A00011]
	-- Add the parameters for the stored procedure here
AS
BEGIN
	declare @count int
	declare @sms_guid varchar(36)
	
	select @COUNT=COUNT(*) from ucis_data_to_44 where TYPE_ID='A00011'
	if @COUNT>0
	begin
		--获取催缴计划
		select top 1 @sms_guid=sms_guid from ucis_data_to_44 where TYPE_ID='A00011'
		if @sms_guid!=''
		begin
			begin
				insert into OPENQUERY(UCIS115,'SELECT * from ucis.CJ_Comprehensive') select * from CJ_Comprehensive_UCIS where sms_guid=@sms_guid
			end
			begin
				insert into OPENQUERY(UCIS115,'SELECT * from ucis.CJ_UpdateType')(GUID,TypeID,DBType,InTime) values(@sms_guid,'A00011',1,GETDATE())
				delete ucis_data_to_44 where TYPE_ID='A00011' and sms_guid=@sms_guid
			end
		end
	end
end